package com.twu.biblioteca;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by jw on 4/28/14.
 */
public class UserList {
    List<User> userList;

    public UserList(){
        userList = new ArrayList<User>();
        Init();
    }

    private List Init(){
        userList.add(new User("000-0001", "123456", "lily","lily@gmail.com", "x"));
        userList.add(new User("000-0002", "123456", "jim","jim@gmial.com","x"));
        userList.add(new User("000-0003", "123456","jack","jack@gmial.com","x"));

        return userList;
    }

    public boolean isUserValid(String uerNum, String password){
        for(int i = 0; i < userList.size();i++)
            if ((userList.get(i).getUserNum().equals(uerNum)) && userList.get(i).getPassword().equals(password))
                return true;
        return false;
    }

    public void printUserInfo(String userNum){
        for (int i=0;i<userList.size();i++){
            if(userList.get(i).getUserNum().equals(userNum))
                System.out.println(userList.get(i).getName()+"  "+userList.get(i).getEmail()+"  "+userList.get(i).getAddress());
        }
    }
}
